package com.tj.jinzao.fragment;

import android.text.InputFilter;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

import com.tj.jinzao.R;
import com.tj.jinzao.activity.CompleteInfoActivity;
import com.tj.jinzao.base.BaseFragment;
import com.tj.jinzao.utils.ToastUtils;
import com.tj.jinzao.utils.Utils;
import com.tj.jinzao.widgets.MaxTextLengthFilter;

import butterknife.BindView;
import butterknife.OnClick;


/**
 * 完善资料1-昵称
 * Created by wjy on 2019/1/6.
 */
public class CompleteInfoStep1Fragment extends BaseFragment {
    @BindView(R.id.et_name)
    EditText mNameView;

    @Override
    protected void setupViews(LayoutInflater inflater, View view) {
        super.setupViews(inflater, view);
        mNameView.setFilters(new InputFilter[]{new MaxTextLengthFilter(12, getActivity(),"昵称限12字以内")});
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_complete_info_step_1;
    }

    @OnClick(R.id.bt_next)
    public void next() {
        Utils.hideSoftInput(mContext, mNameView);
        if (mContext instanceof CompleteInfoActivity) {
            String name = mNameView.getText().toString().trim();
            if (!TextUtils.isEmpty(name)) {
                ((CompleteInfoActivity) mContext).setData("nickname", name);
            }else {
                ToastUtils.showToast(getActivity(),"请输入昵称");
                return;
            }
            ((CompleteInfoActivity) mContext).next();
        }
    }

}
